<?php
/* SVN FILE: $Id: breadcrumbs.php 57 2007-10-02 23:18:39Z joe.vasquez $ */
/**
 * breadcrumb component
 * @filesource
 * @author			Joe Vasquez <joe.vasquez@gmail.com>
 * @copyright		Copyright (c) 2007, Joe Vasquez
 * @package			redlettr
 * @subpackage		components
 * @since			0.1A
 * @version			0.1A  $Rev: 57 $
 * @lastmodified	$Date: 2007-10-02 23:18:39 +0000 (Tue, 02 Oct 2007) $
 * @license			http://www.gnu.org/licenses/gpl.html GNU General Public License
 */
 
class BreadcrumbsComponent extends Object {
	var $__crumbs		= null;
	var $__separator	= '&gt;';
	var $controller 	= true;
	
	function startup(&$controller)
	{
		$this->controller = $controller;
	}
	
/**
 * addCrumb
 * 
 * adds crumbs to crumb array
 * 
 * @param string name string to display
 * @param string link url to link to, if not defined set to /name
 */	
	function addCrumb($name,$link = null)
	{
		if(!is_array($this->__crumbs))
		{
			$this->__crumbs = array();
		}
		if(isset($link))
		{
			$this->__crumbs[] = array($name,$link);
		} else {
			$this->__crumbs[] = array(ucfirst($name),'/'.$name);
		}
	}

/**
 * hasCrumbs
 * 
 * @return bool true if __crumbs is an array
 */	
	function hasCrumbs()
	{
		return is_array($this->__crumbs);
	}

	function setCrumbs()
	{	
		$this->controller->set('crumbsList',$this->__crumbs);
	}
}
?>